import { get, post, del } from '../utils/request';
import { ApiResponse, Comment, PageResult } from '../types';

/**
 * 获取种子评论列表
 */
export function getTorrentComments(torrentId: number, params?: {
  page?: number;
  size?: number;
}) {
  return get<ApiResponse<PageResult<Comment>>>('/comments/torrent/' + torrentId, params);
}

/**
 * 发表评论
 */
export function addComment(data: {
  torrentId: number;
  content: string;
  parentId?: number;
}) {
  return post<ApiResponse<Comment>>('/comments', data);
}

/**
 * 点赞评论
 */
export function likeComment(commentId: number) {
  return post<ApiResponse<null>>(`/comments/${commentId}/like`);
}

/**
 * 取消点赞评论
 */
export function unlikeComment(commentId: number) {
  return del<ApiResponse<null>>(`/comments/${commentId}/like`);
}

/**
 * 删除评论
 */
export function deleteComment(commentId: number) {
  return del<ApiResponse<null>>(`/comments/${commentId}`);
} 